package com.atguigu.chapter02

object Test03 {
  def main(args: Array[String]): Unit = {
    def sayHi(name:String): Unit={
      //println(s"hi  $name")
      def changeName():String={
        s"hi $name  nihao"
      }
      println(s"调用 ${changeName()}")
    }
    //sayHi("zhangsan")
    sayHi("lisi")
    val a:Char = 'a'
    val a1:Char = 97
    println(a)
    println(a1)

    //    2）函数可以作为参数进行传递
    def sumAB(a: Int, b: Int): Int = a + b

    def difAB(a: Int, b: Int): Int = a - b

    // 给两个数 ,之后按照传入的公式进行计算
    def funcAB(a: Int, b: Int, func: (Int, Int) => Int): Int = {
      func(a, b)
    }


    val i: Int = funcAB(10, 20, difAB)
    println(i)


    val b1: Int = funcAB(10, 20, 2 * _ / 4 *_)
    println(b1)
  }

}
